﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
using Bifrost;
using TextEditor.TextDocument.Control;

namespace TextEditor
{
    public class ZYTextBapfMark : ZYTextElement
    {
        /// <summary>
        /// 多媒体
        /// </summary>
        AutoShowBapfMeg pb;
        public ZYTextBapfMark()
        {
        }

        private string mediaPath = string.Empty;

        public string MediaPath
        {
            get { return mediaPath; }
            set { mediaPath = value; }
        }


        public void ExcuteAdd()
        {
            pb = new AutoShowBapfMeg(this);
        }

        public override bool FromXML(XmlElement myElement)
        {
            base.FromXML(myElement);
            pb = new AutoShowBapfMeg(this);
            return true;
        }

        public override string GetXMLName()
        {
            return "bapf";
        }

        public override bool RefreshSize()
        {
            if (!base.myOwnerDocument.Info.Printing)
            {
                this.intWidth = 2;// Properties.Resources.media.Width;
                this.intHeight = 17;//Properties.Resources.media.Height;
            }
            else
            {
                this.intWidth = 0;
                this.intHeight = 0;
            }
            return true;
        }


        public override bool ToXML(XmlElement myElement)
        {
            return base.ToXML(myElement);
        }

        public override bool HandleMouseMove(int x, int y, MouseButtons Button)
        {
            if (this.Bounds.Contains(x, y))
            {
                base.myOwnerDocument.SetCursor(Cursors.Arrow);
            }
            return false;
        }

        public override bool HandleDblClick(int x, int y, MouseButtons Button)
        {
            if (!base.OwnerDocument.Locked)
            {
                //if (this.Bounds.Contains(x, y))
                //{
                //}
            }
            return true;
        }


        public override bool RefreshView()
        {
            if (!base.OwnerDocument.OwnerControl.Controls.Contains(pb))
                base.OwnerDocument.OwnerControl.Controls.Add(pb);

            if (pb.Visible == false)
                pb.Visible = true;
            if (this.Height > 0)
            {
                this.OwnerDocument.View.Graph.DrawLine(Pens.Red, this.RealLeft, this.RealTop, this.RealLeft, this.RealTop + this.Height);
            }
            return true;
        }

        public override string ToZYString()
        {
            return "";
        }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string Value
        {
            get
            {
                return base.myAttributes.GetString("value");
            }
            set
            {
                base.myAttributes.SetValue("value", value);
            }
        }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string DoctorName
        {
            get
            {
                return base.myAttributes.GetString("doctor_name");
            }
            set
            {
                base.myAttributes.SetValue("doctor_name", value);
            }
        }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string FilePath
        {
            get
            {
                return base.myAttributes.GetString("file_path");
            }
            set
            {
                base.myAttributes.SetValue("file_path", value);
            }
        }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string IsUpdate
        {
            get
            {
                return base.myAttributes.GetString("update");
            }
            set
            {
                base.myAttributes.SetValue("update", value);
            }
        }

        /// <summary>
        /// 文件名称
        /// </summary>
        public string DoctorId
        {
            get
            {
                return base.myAttributes.GetString("doctor_id");
            }
            set
            {
                base.myAttributes.SetValue("doctor_id", value);
            }
        }
    }
}
